import React from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux'

import Password from '../components/smart/Password'

import Information from '../components/dumb/Information';

import { store } from '../store'

import { getVerificationCode } from '../actions/authentication';

class Test extends React.Component {
    static propTypes = {
        name: React.PropTypes.string,
    };

    unsubscribe = null;

    constructor(props) {
        super(props);
    }

    componentDidMount() {
        let { dispatch } = this.props;
        // dispatch(push('/app/foo'));
        this.unsubscribe = store.subscribe(() => {
            console.log('get', store.getState());
        });

        try {
            dispatch(getVerificationCode())
        }
        catch(e) {
            dispatch(infor(e.message))
        }
    }

    componentWillUnmount() {
        this.unsubscribe();
    }

    render() {
        let { children } = this.props;
        return (
            <div>
                <h1 style={{'color': 'red'}}></h1>
                <div>
                    <Password />
                </div>
                <div>
                    {children}
                </div>
                <Information label="Hello World" isOpen={false} />
            </div>
        );
    }
}

export default connect((state)=>state)(Test);